
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list: [{
      code: "0001",
      name: "无人机",
      name1: "黑色",
      url: "http://i1.mifile.cn/a1/pms_1487824962.01314237!220x220.jpg",
      style: "低配版",
      select: "circle",
      num: "1",
      rmb1: '0.00',
      rmb2: '1.00',
      del: '../../images/del.png'
    },
    {
      code: "0001",
      name: "无人机",
      name1: "黑色",
      url: "http://i1.mifile.cn/a1/pms_1487824962.01314237!220x220.jpg",
      style: "低配版",
      select: "circle",
      num: "1",
      rmb1: '0.00',
      rmb2: '1.00',
      del: '../../images/del.png'
    }
    ],
    hostUrl: app.globalData.hostUrl,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var userId = wx.getStorageSync('userId');
    that.foot(userId);//收藏内容
  },
  foot: function (userId) {
    var that = this;
    wx.request({
      url: app.globalData.apiUrl + 'User/foot',
      data: {
        userId: userId,
      },
      header: {
        'content-type': 'application/json'
      },
      success: function (res) {
        console.log(res)
        if (res.data != null) {
          that.setData({

            list: res.data,

          })
        }
      }
    })
  },
  //取消收藏
  del_shoucang: function (e) {
    console.log(e)
    var that = this;
    var id = e.currentTarget.dataset.id;
    wx.request({
      url: app.globalData.apiUrl + 'User/footdel',
      data: {
        id: id,
      },
      header: {
        'content-type': 'application/json'
      },
      success: function (res) {
        console.log(res)
        if (res.data.status == 1) {
          wx.showToast({
            title: res.data.msg,
            icon: 'none'
          })
          that.onLoad();
        } else {
          wx.showToast({
            title: res.data.msg,
            icon: 'none'
          })
        }
      }
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})